|
|
 |
|
|
|
|
' Play the animation. Private Sub PlayImages(ByVal ms_per_frame As Long)
Dim frame As Integer
Dim stock As Integer
Dim next_time As Long
' Start the animation. next_time = GetTickCount()
For frame = 1 To NUM_FRAMES
' Restore the background. picGraph.Cls
' Draw the stock data. For stock = 1 To NUM_STOCKS
If Data(frame, stock) > 50 Then
picGraph.Line (stock, 0) - _
(stock + 0.75, 50), _
vbRed, BF
picGraph.Line (stock, 50) - _
(stock + 0.75, Data(frame, stock)), _
vbGreen, BF
Else
picGraph.Line (stock, 0)- _
(stock + 0.75, Data(frame, stock)), _
vbRed, BF
End If
Next stock
picGraph.Line (0, 50)- _
(NUM_STOCKS + 1.25, 50), vbBlack, BF
lblDay.Caption = Format$(frame)
' Wait until it's time for the next frame. next_time = next_time + ms_per_frame
WaitTill next_time
If Not Playing Then Exit For
Next frame
End Sub |
|
|
|
|
|
|
|
|
Program Stocks1 animates a series of precomputed values. That makes sense for a stock application that displays historical data. |
|
|
|
|
|
|
|
|
Example program Bounce1, shown in Figure 8.3, takes a different approach. This program displays a collection of balls bouncing in front of a background of rectangles. Instead of using precomputed data, program Bounce1 generates the data it needs as it displays the frames. |
|
|
|
|
|
|
|
|
The following code shows how program Bounce1 displays its collection of bouncing balls. The BallX and BallY arrays store the balls' coordinates. BallDx and BallDy store the distances in pixels that each ball moves between frames. The BallRadius and BallColor |
|
|
|
|
|